﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ModulesPage.Master" AutoEventWireup="true" CodeBehind="RoomManagementAndCreation.aspx.cs" Inherits="SwenAssignment3.RoomAvailabilityCumBookingModule.RoomManagement_Creation" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
        // This Script is used to maintain Grid Scroll on Partial Postback
        var scrollTop;
        //Register Begin Request and End Request 
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        //Get The Div Scroll Position
        function BeginRequestHandler(sender, args) 
        {
            var m = document.getElementById('divGrid');
            scrollTop=m.scrollTop;
        }

        //Set The Div Scroll Position
        function EndRequestHandler(sender, args)
        {
            var m = document.getElementById('divGrid');
            m.scrollTop = scrollTop;
        } 
    </script>
    <style type="text/css">
        .HeaderFreez
        {
           position:relative ;
           top:expression(this.offsetParent.scrollTop);
           z-index: 10;
        }
        </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div id="divGrid" style="overflow: auto; height: 580px">
                <asp:DetailsView ID="DetailsView1" ForeColor="#333333" runat="server" Height="50px" Width="337px" AutoGenerateRows="False" DataKeyNames="RoomNo" DataSourceID="SqlDataSource1" CellPadding="4" GridLines="None">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                    <EditRowStyle BackColor="#999999" />
                    <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                    <Fields>
                        <asp:BoundField DataField="RoomNo" HeaderText="RoomNo" ReadOnly="True" SortExpression="RoomNo" />
                        <asp:BoundField DataField="Floor" HeaderText="Floor" SortExpression="Floor" />
                        <asp:BoundField DataField="RoomType" HeaderText="RoomType" SortExpression="RoomType" />
                        <asp:BoundField DataField="BedType" HeaderText="BedType" SortExpression="BedType" />
                        <asp:BoundField DataField="SmokingOrNot" HeaderText="SmokingOrNot" SortExpression="SmokingOrNot" />
                        <asp:BoundField DataField="MaxOccupancy" HeaderText="MaxOccupancy" SortExpression="MaxOccupancy" />
                        <asp:BoundField DataField="RoomRates" HeaderText="RoomRates" SortExpression="RoomRates" />
                        <asp:BoundField DataField="RoomStatus" HeaderText="RoomStatus" SortExpression="RoomStatus" />
                        <asp:BoundField DataField="MaintainedBy" HeaderText="MaintainedBy" SortExpression="MaintainedBy" />
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" />
                    </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="Data Source=USER-MSI\MSSQLSERVER2012;Initial Catalog=DRHotelDB;User ID=sa;Password=imsa" 
                    ProviderName="System.Data.SqlClient"
                    InsertCommand="INSERT INTO [Rooms] ([RoomNo], [Floor], [RoomType], [BedType], [SmokingOrNot], [MaxOccupancy], [RoomRates], [RoomStatus], [MaintainedBy]) VALUES (@RoomNo, @Floor, @RoomType, @BedType, @SmokingOrNot, @MaxOccupancy, @RoomRates, @RoomStatus, @MaintainedBy)" 
                    SelectCommand="SELECT * FROM [Rooms] WHERE ([RoomNo] = @RoomNo)" ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [Rooms] WHERE [RoomNo] = @original_RoomNo AND (([Floor] = @original_Floor) OR ([Floor] IS NULL AND @original_Floor IS NULL)) AND (([RoomType] = @original_RoomType) OR ([RoomType] IS NULL AND @original_RoomType IS NULL)) AND (([BedType] = @original_BedType) OR ([BedType] IS NULL AND @original_BedType IS NULL)) AND (([SmokingOrNot] = @original_SmokingOrNot) OR ([SmokingOrNot] IS NULL AND @original_SmokingOrNot IS NULL)) AND (([MaxOccupancy] = @original_MaxOccupancy) OR ([MaxOccupancy] IS NULL AND @original_MaxOccupancy IS NULL)) AND (([RoomRates] = @original_RoomRates) OR ([RoomRates] IS NULL AND @original_RoomRates IS NULL)) AND (([RoomStatus] = @original_RoomStatus) OR ([RoomStatus] IS NULL AND @original_RoomStatus IS NULL)) AND (([MaintainedBy] = @original_MaintainedBy) OR ([MaintainedBy] IS NULL AND @original_MaintainedBy IS NULL))" OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [Rooms] SET [Floor] = @Floor, [RoomType] = @RoomType, [BedType] = @BedType, [SmokingOrNot] = @SmokingOrNot, [MaxOccupancy] = @MaxOccupancy, [RoomRates] = @RoomRates, [RoomStatus] = @RoomStatus, [MaintainedBy] = @MaintainedBy WHERE [RoomNo] = @original_RoomNo AND (([Floor] = @original_Floor) OR ([Floor] IS NULL AND @original_Floor IS NULL)) AND (([RoomType] = @original_RoomType) OR ([RoomType] IS NULL AND @original_RoomType IS NULL)) AND (([BedType] = @original_BedType) OR ([BedType] IS NULL AND @original_BedType IS NULL)) AND (([SmokingOrNot] = @original_SmokingOrNot) OR ([SmokingOrNot] IS NULL AND @original_SmokingOrNot IS NULL)) AND (([MaxOccupancy] = @original_MaxOccupancy) OR ([MaxOccupancy] IS NULL AND @original_MaxOccupancy IS NULL)) AND (([RoomRates] = @original_RoomRates) OR ([RoomRates] IS NULL AND @original_RoomRates IS NULL)) AND (([RoomStatus] = @original_RoomStatus) OR ([RoomStatus] IS NULL AND @original_RoomStatus IS NULL)) AND (([MaintainedBy] = @original_MaintainedBy) OR ([MaintainedBy] IS NULL AND @original_MaintainedBy IS NULL))">
                    <DeleteParameters>
                        <asp:Parameter Name="original_RoomNo" Type="Int32" />
                        <asp:Parameter Name="original_Floor" Type="Int32" />
                        <asp:Parameter Name="original_RoomType" Type="String" />
                        <asp:Parameter Name="original_BedType" Type="String" />
                        <asp:Parameter Name="original_SmokingOrNot" Type="String" />
                        <asp:Parameter Name="original_MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="original_RoomRates" Type="Decimal" />
                        <asp:Parameter Name="original_RoomStatus" Type="String" />
                        <asp:Parameter Name="original_MaintainedBy" Type="String" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="RoomNo" Type="Int32" />
                        <asp:Parameter Name="Floor" Type="Int32" />
                        <asp:Parameter Name="RoomType" Type="String" />
                        <asp:Parameter Name="BedType" Type="String" />
                        <asp:Parameter Name="SmokingOrNot" Type="String" />
                        <asp:Parameter Name="MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="RoomRates" Type="Decimal" />
                        <asp:Parameter Name="RoomStatus" Type="String" />
                        <asp:Parameter Name="MaintainedBy" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridView1" Name="RoomNo" PropertyName="SelectedValue" Type="Int32" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Floor" Type="Int32" />
                        <asp:Parameter Name="RoomType" Type="String" />
                        <asp:Parameter Name="BedType" Type="String" />
                        <asp:Parameter Name="SmokingOrNot" Type="String" />
                        <asp:Parameter Name="MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="RoomRates" Type="Decimal" />
                        <asp:Parameter Name="RoomStatus" Type="String" />
                        <asp:Parameter Name="MaintainedBy" Type="String" />
                        <asp:Parameter Name="original_RoomNo" Type="Int32" />
                        <asp:Parameter Name="original_Floor" Type="Int32" />
                        <asp:Parameter Name="original_RoomType" Type="String" />
                        <asp:Parameter Name="original_BedType" Type="String" />
                        <asp:Parameter Name="original_SmokingOrNot" Type="String" />
                        <asp:Parameter Name="original_MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="original_RoomRates" Type="Decimal" />
                        <asp:Parameter Name="original_RoomStatus" Type="String" />
                        <asp:Parameter Name="original_MaintainedBy" Type="String" />
                    </UpdateParameters>
                </asp:SqlDataSource>
                <asp:GridView ID="GridView1" runat="server" ForeColor="#333333" GridLines="Vertical" AutoGenerateColumns="False" DataKeyNames="RoomNo" DataSourceID="SqlDataSource2" AllowPaging="True">
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <HeaderStyle CssClass="HeaderFreez" />
                    <Columns>
                        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                        <asp:BoundField DataField="RoomNo" HeaderText="RoomNo" ReadOnly="True" SortExpression="RoomNo" />
                        <asp:BoundField DataField="Floor" HeaderText="Floor" SortExpression="Floor" />
                        <asp:BoundField DataField="RoomType" HeaderText="RoomType" SortExpression="RoomType" />
                        <asp:BoundField DataField="BedType" HeaderText="BedType" SortExpression="BedType" />
                        <asp:BoundField DataField="SmokingOrNot" HeaderText="SmokingOrNot" SortExpression="SmokingOrNot" />
                        <asp:BoundField DataField="MaxOccupancy" HeaderText="MaxOccupancy" SortExpression="MaxOccupancy" />
                        <asp:BoundField DataField="RoomRates" HeaderText="RoomRates" SortExpression="RoomRates" />
                        <asp:BoundField DataField="RoomStatus" HeaderText="RoomStatus" SortExpression="RoomStatus" />
                        <asp:BoundField DataField="MaintainedBy" HeaderText="MaintainedBy" SortExpression="MaintainedBy" />
                    </Columns>
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#999999" />
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConflictDetection="CompareAllValues" ConnectionString="Data Source=USER-MSI\MSSQLSERVER2012;Initial Catalog=DRHotelDB;User ID=sa;Password=imsa" DeleteCommand="DELETE FROM [Rooms] WHERE [RoomNo] = @original_RoomNo" InsertCommand="INSERT INTO [Rooms] ([RoomNo], [Floor], [RoomType], [BedType], [SmokingOrNot], [MaxOccupancy], [RoomRates], [RoomStatus], [MaintainedBy]) VALUES (@RoomNo, @Floor, @RoomType, @BedType, @SmokingOrNot, @MaxOccupancy, @RoomRates, @RoomStatus, @MaintainedBy)" OldValuesParameterFormatString="original_{0}" ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM [Rooms] ORDER BY [RoomNo]" UpdateCommand="UPDATE [Rooms] SET [Floor] = @Floor, [RoomType] = @RoomType, [BedType] = @BedType, [SmokingOrNot] = @SmokingOrNot, [MaxOccupancy] = @MaxOccupancy, [RoomRates] = @RoomRates, [RoomStatus] = @RoomStatus, [MaintainedBy] = @MaintainedBy WHERE [RoomNo] = @original_RoomNo">
                    <DeleteParameters>
                        <asp:Parameter Name="original_RoomNo" Type="Int32" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="RoomNo" Type="Int32" />
                        <asp:Parameter Name="Floor" Type="Int32" />
                        <asp:Parameter Name="RoomType" Type="String" />
                        <asp:Parameter Name="BedType" Type="String" />
                        <asp:Parameter Name="SmokingOrNot" Type="String" />
                        <asp:Parameter Name="MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="RoomRates" Type="Decimal" />
                        <asp:Parameter Name="RoomStatus" Type="String" />
                        <asp:Parameter Name="MaintainedBy" Type="String" />
                    </InsertParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="Floor" Type="Int32" />
                        <asp:Parameter Name="RoomType" Type="String" />
                        <asp:Parameter Name="BedType" Type="String" />
                        <asp:Parameter Name="SmokingOrNot" Type="String" />
                        <asp:Parameter Name="MaxOccupancy" Type="Int32" />
                        <asp:Parameter Name="RoomRates" Type="Decimal" />
                        <asp:Parameter Name="RoomStatus" Type="String" />
                        <asp:Parameter Name="MaintainedBy" Type="String" />
                        <asp:Parameter Name="original_RoomNo" Type="Int32" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>
